﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace RPGGameLibrary
{
    public class Camera
    {
        public CameraController CameraController;
        public Map LocalMap;
        public BoundingSphere CameraSphere = new BoundingSphere();
        public Camera(Map _LocalMap)
        {
            CameraController = new CameraController(this);
            Location = new Vector3(-500, 110, 50);
            LocalMap = _LocalMap;
            
        }
        public Vector3 Location;
   
        public void Update()
        {
            CameraSphere.Center = Location;
            CameraSphere.Radius = 10;
            CameraController.Update();
           // Location = CameraController.Cam.Location;
        }
        public bool  collusion()
        {
         
           foreach (var p in LocalMap.WorldMeshList)
           {
              
               foreach (var q in p._Model.Meshes)
               {
                   BoundingSphere Bound = q.BoundingSphere;
                   Bound.Center = p.position;
                   if (CameraSphere.Intersects(Bound))
                   {
                       return true;
                   }
                 
               }
                
               
           }
           return false;
        }
        public bool collusion(Vector3 NewLoc)
        {

            foreach (var p in LocalMap.WorldMeshList)
            {

                foreach (var q in p._Model.Meshes)
                {
                    BoundingSphere Bound = q.BoundingSphere;
                    Bound.Center = p.position;
                    CameraSphere.Center = NewLoc;
                    if (CameraSphere.Intersects(Bound))
                    {
                        return true;
                    }

                }


            }
            return false;
        }
    }
}
